/*
 *   Copyright 1999-2016 Asiainfo Technologies(China),Inc.
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 */

package com.asiainfo.redis.entity;

import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.springframework.data.redis.connection.ClusterInfo;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.List;

/**
 * @version v 1.0 on 2016/3/3 15:44
 * @auther william.xu
 */

@Entity
@Table(name="REDIS_CLUSTER")
@SequenceGenerator(name="REDIS_CLUSTER_SEQ_",sequenceName="REDIS_CLUSTER_SEQ",allocationSize=1)
public class Cluster {

    @Id
    @GeneratedValue(strategy= GenerationType.SEQUENCE,generator="REDIS_CLUSTER_SEQ_")
    @Column(name = "ID")
    private Long id;

    @Column(name = "CLUSTER_NAME")
    private String clusterName;

    @Column(name = "TYPE")
    private Integer type = 0;

    @Column(name = "STANDBY_ID")
    private Long standbyId;

    @Transient
    private ClusterNodeConfig clusterNodeConfig;

    @Transient
    private List<ClusterNode> masterNodes;

    @Transient
    private String state;//集群状态
    @Transient
    private ClusterInfo clusterInfo;//具体集群信息


    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getClusterName() {
        return clusterName;
    }

    public void setClusterName(String clusterName) {
        this.clusterName = clusterName;
    }

    public ClusterNodeConfig getClusterNodeConfig() {
        return clusterNodeConfig;
    }

    public void setClusterNodeConfig(ClusterNodeConfig clusterNodeConfig) {
        this.clusterNodeConfig = clusterNodeConfig;
    }

    public List<ClusterNode> getMasterNodes() {
        return masterNodes;
    }

    public void setMasterNodes(List<ClusterNode> masterNodes) {
        this.masterNodes = masterNodes;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public ClusterInfo getClusterInfo() {
        return clusterInfo;
    }

    public void setClusterInfo(ClusterInfo clusterInfo) {
        this.clusterInfo = clusterInfo;
    }


    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Long getStandbyId() {
            return standbyId;
    }

    public void setStandbyId(Long standbyId) {
        this.standbyId = standbyId;
    }

    public String toString(){
        return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
    }

}
